package org.dingyom;

import org.dingyom.user.interceptor.LoginInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 入口类
 */
@SpringBootApplication
@MapperScan("org.dingyom.*.mapper")
@EnableCaching//启用缓存
public class CarAppStart implements WebMvcConfigurer {
    public static void main(String[] args) {
        SpringApplication.run(CarAppStart.class, args);
    }

    @Autowired
    LoginInterceptor loginInterceptor;
    //拦截器配置
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                //拦截地址
                .addPathPatterns("/**")
                //放行地址
                .excludePathPatterns("/logininfo/account")//登陆
                .excludePathPatterns("/logininfo/accountBySms")//短信登陆
                .excludePathPatterns("/user/register/**")//注册
                .excludePathPatterns("/verification/**")//验证码
                .excludePathPatterns("/fastDfs")//资源文件
                ;
    }
}
